Skip to content

Conversation

tarunsinghofficial
Copy link
Collaborator

Fixes #189

Changes

  • Added the measureLinksWidth function to use actual link text for accurate width measurement.
  • Ensured responsive behavior remains intact by maintaining accurate width calculations.
  • Adjusted the layout and positioning of the burger icon to ensure it is correctly aligned.

Screenshot:
PugetSound-GoogleChrome2025-02-2821-14-38-ezgif com-video-to-gif-converter

@coveralls
Copy link

coveralls commented Feb 28, 2025

Coverage Status

coverage: 15.527% (-1.0%) from 16.487%
when pulling a32d249 on tarunsinghofficial:fix-navbar
into 4220475 on OneBusAway:main.

Copy link
Member

@aaronbrethorst aaronbrethorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good! The behavior feels great. I have some nitpicks about the code I'd like to see addressed before merging, but hopefully they should all be quick.

let shouldShowMobile = $state(false);
let navContainer;
let linksContainer = $state(null);
let linksWidthCache = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename this to cachedLinksWidth

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

}
function measureLinksWidth() {
if (headerLinks && !linksContainer) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use an early return instead of deep nesting:

if (!headerLinks || linksContainer) {
  return;
}

Note: this logic ^^ may be incorrect! You'll need to test and validate!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, correct. I have updated the function to use an early return to avoid deep nesting and make the code more readable.

tempDiv.style.position = 'absolute';
tempDiv.style.visibility = 'hidden';
tempDiv.style.display = 'flex';
tempDiv.style.gap = '1rem';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where does the gap here and the padding on line 62 come from? Are these derived from the current style values on the page? If so, those should be reused somehow in case the styling changes later.

Copy link
Collaborator Author

@tarunsinghofficial tarunsinghofficial Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gap and padding are derived from actual style values used in the page here (<a href={value} class="block px-2 py-1 font-semibold text-gray-900 dark:text-white" >{key}</a >).

For ease, I've now defined constants in the file with clear comments explaining which Tailwind classes they correspond to.

Note: If the styles change later, we just have to update these constants according to the corresponding Tailwind classes from the template. That's the best & easiest approach to implement, I think :)

Copy link
Member

@aaronbrethorst aaronbrethorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@aaronbrethorst aaronbrethorst merged commit 86cefc7 into OneBusAway:main Mar 21, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent x-axis overflow
3 participants